package com.snap.awesomeserial.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.snap.awesomeserial.AppConfig;
import com.snap.awesomeserial.R;
import com.snap.awesomeserial.base.BaseActivity;
import com.snap.awesomeserial.bean.SettingInfo;
import com.snap.awesomeserial.model.ConfigManager;
import com.snap.awesomeserial.ui.widget.DialogView2;
import com.snap.awesomeserial.utils.RootShellCmd;

import butterknife.BindView;

/**
 * //彩蛋页面
 * Created by Eason on 2019-07-25 .
 */
public class EggActivity extends BaseActivity {

    @BindView(R.id.setting_btn)
    ImageView settingImg;
    @BindView(R.id.title_tv)
    TextView titleTv;

    @BindView(R.id.identification_tv)
    TextView identificationTv;
    @BindView(R.id.light_base_tv)
    TextView lightBaseTv;


    @Override
    protected int layoutResId() {
        return R.layout.activity_egg;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        settingImg.setVisibility(View.GONE);
        titleTv.setText("动态配置");
        SettingInfo settingInfo = ConfigManager.getInstance().getSettingInfo();

        //序列号配置
        identificationTv.setText(settingInfo.getSn());
        identificationTv.setOnClickListener(v -> new DialogView2(EggActivity.this)
                .setTitle("序列号配置")
                .setHint("请输入序列号")
                .setEditContent(identificationTv.getText().toString())
                .setOnClickListener(content -> {
                    identificationTv.setText(content);
                    settingInfo.setSn(content);
                    ConfigManager.getInstance().update();
                }).show());

        //荧光基数配置
        lightBaseTv.setText(String.valueOf(settingInfo.getLightBase()));
        lightBaseTv.setOnClickListener(v -> new DialogView2(EggActivity.this)
                .setTitle("荧光基数配置")
                .setHint("荧光基数")
                .setEditContent(lightBaseTv.getText().toString())
                .setOnClickListener(content -> {
                    int value = Integer.valueOf(content);
                    lightBaseTv.setText(String.valueOf(value));
                    settingInfo.setLightBase(value);
                    ConfigManager.getInstance().update();
                }).show());

    }

    public void escape(View v) {
        RootShellCmd.getInstance().escape();
        RootShellCmd.getInstance().showNavigation();
    }

    public void hideNavigation(View v) {
        RootShellCmd.getInstance().hideNavigation();
    }
}